package com.home.demo.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.home.demo.entity.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.home.demo.entity.BeOnDutyEntity;
import com.home.demo.service.BeOnDutyService;
import com.home.demo.common.utils.PageUtils;
import com.home.demo.common.utils.R;



/**
 * 
 *
 * @author ${author}
 * @email ${email}
 * @date 2024-04-20 16:22:39
 */
@RestController
@RequestMapping("demo/beonduty")
public class BeOnDutyController {
    @Autowired
    private BeOnDutyService beOnDutyService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = beOnDutyService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 获取值班医生下拉框
     */
    @GetMapping("getZhiBanYiSheng")
    public R getZhiBanYiSheng (String time,String flag){
        String userEntity = beOnDutyService.listInfo(time,flag);
        return R.ok().put("data",userEntity);
    }



    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
		BeOnDutyEntity beOnDuty = beOnDutyService.getById(id);

        return R.ok().put("data", beOnDuty);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BeOnDutyEntity beOnDuty){
		beOnDutyService.save(beOnDuty);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BeOnDutyEntity beOnDuty){
		beOnDutyService.updateById(beOnDuty);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] ids){
		beOnDutyService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
